package cn.ac.big.bigd.util;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtils {
    public static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
    public static final DateFormat DATE_FORMAT2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");

    public static String format(Date date) {
        if (date == null) {
            return "";
        } else {
            return DATE_FORMAT.format(date);
        }

    }
    public static String formatTime(Date date) {
        if (date == null) {
            return "";
        } else {
            return DATE_FORMAT2.format(date);
        }

    }
    public static Date parse(String date) throws  Exception {

            return DATE_FORMAT.parse(date);


    }

    public static String transForDate(String ms){
        System.out.println(ms);

        String str="";
        if(ms!=null){
            long msl=Long.valueOf(ms);
            SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
            try {
                 str=sdf.format(msl);
            } catch (Exception e) {
                e.printStackTrace();
                return  "";
            }
        }
        return str;
    }
}
